package com.five.api.service.impl;


import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.five.api.dao.CourseCommentMapper;
import com.five.api.service.CourseCommentService;
import com.five.entity.CourseComment;
import com.five.entity.User;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * <p>
 * 课程评论表 服务实现类
 * </p>
 *
 * @author star
 * @since 2021-06-16
 */
@Service
public class CourseCommentServiceImpl extends ServiceImpl<CourseCommentMapper, CourseComment> implements CourseCommentService {

    @Autowired
    private CourseCommentMapper courseCommentMapper;

    private Logger logger = LoggerFactory.getLogger(CourseCommentServiceImpl.class);

    @Override
    public List<CourseComment>  selectCourseContent(Integer courseId) {

        List<CourseComment> courseComments = courseCommentMapper.selectCourseComment(courseId);
        logger.debug("课程评论："+courseComments.toString());

        return courseComments;
    }

    @Override
    public int insertCourseComment(String content, Long courseId, Long userId) {
        int i = courseCommentMapper.insertCourseComment(content, courseId, userId);
        return i;
    }

    @Override
    public User selUserIdByUserName(String username) {
        System.out.println("----------");
        System.out.println(username);
        User user = courseCommentMapper.selUserIdByUserName(username);
        System.out.println(user);
        System.out.println("----------");
        return user;
    }
}
